package com.github.wxiaoqi.security.common.util;

import com.github.wxiaoqi.security.common.constant.CommonConstants;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 查询参数
 * @author dzl
 */
public class Query extends LinkedHashMap<String, Object>
{
    private static final long serialVersionUID = 1L;

    /**
     * 当前页码
     */
    private int page = 1;

    /**
     * 每页条数
     */
    private int limit = 10;
    
    public Query(Map<String, Object> params)
    {
        this.putAll(params);
        // 分页参数
        if (params.get(CommonConstants.CHARACTER_PAGE) != null)
        {
            this.page = Integer.parseInt(params.get(CommonConstants.CHARACTER_PAGE).toString());
        }
        if (params.get(CommonConstants.CHARACTER_LIMIT) != null)
        {
            this.limit = Integer.parseInt(params.get(CommonConstants.CHARACTER_LIMIT).toString());
        }
        this.remove(CommonConstants.CHARACTER_PAGE);
        this.remove(CommonConstants.CHARACTER_LIMIT);
    }
    
    public int getPage()
    {
        return page;
    }
    
    public void setPage(int page)
    {
        this.page = page;
    }
    
    public int getLimit()
    {
        return limit;
    }
    
    public void setLimit(int limit)
    {
        this.limit = limit;
    }
}
